package com.wisesoft.ncp.service.impl;

import com.wisesoft.ncp.entity.VirusEntity;
import com.wisesoft.ncp.repo.VirusRepository;
import com.wisesoft.ncp.service.VirusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lvchang on 2020/3/9.
 */
@Service
public class VirusServiceImpl implements VirusService{

    @Autowired
    private VirusRepository virusRepository;

    @Override
    public List<VirusEntity> findAll() {
        return virusRepository.findAll();
    }

    @Override
    public List<VirusEntity> findByNumberLessThan(int number) {
        return virusRepository.findByNumberLessThan(number);
    }

    @Override
    public void update(VirusEntity virus) throws Exception {
        virusRepository.updateByDistrict(virus.getId(), virus.getDistrict(), virus.getNumber());
    }

    @Override
    public void deleteById(Long id) {
        virusRepository.deleteById(id);
    }
}
